package com.stylefeng.guns.gateway.common;

/**
 * 存储线程的userId
 */
public class CurrentUser {

    /**
     * 线程切换时也能保存数据，应对Hystrix
     */
    private static final InheritableThreadLocal<String> threadLocal = new InheritableThreadLocal<>();

    public static void saveUserId(String userId){
        threadLocal.set(userId);
    }

    public static String getUserId(){
        return threadLocal.get();
    }
}
